﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Lonewolf.WebApp.Models;
using Lonewolf.Entity;
using Microsoft.EntityFrameworkCore;
using Lonewolf.Infrastructure;
using Lonewolf.IService;
using System.Transactions;
using Lonewolf.Service;


namespace Lonewolf.WebApp.Controllers
{
    public class HomeController : AuthController
    {
        //private readonly IUserService _context;
        //public IUserService _context { get; set; }
        //public IRoleInfoService _roleInfo { get; set; }
        //public  IUnitOfWork _unitOfWork { get; set; }
        //public HomeController(IUnitOfWork unitOfWork)
        //{
        //    _unitOfWork = unitOfWork;
        //}
        // private readonly IUserService _user;
        //public 构造函数名称(IUserService user)
        //{
        //   _user = user;
        //}
        //或者直接这样
        //public IUserService _userInfo { get; set; }

        //在某个方法下获取User表的List
        //var list = _user.Query();
        //或者
        //var list = _userInfo.Query();
        public IActionResult Index()
        {
            // 数据库连接
            //var connectionString = @"server=127.0.0.1;Database=Lonewolf_WebApp;uid=root;pwd=12131124;charset=utf8;";

            //// 需要解析的数据库
            //var database = new List<string> { "Lonewolf_WebApp" };
            //var entities= EntityHelper.GetEntities(connectionString);

            //RoleInfo roleInfo = new RoleInfo();
            //roleInfo.Id = "abc123";//Guid.NewGuid().ToString("N");
            //roleInfo.Name = "管理员";
            //User user = new User();
            //user.Guid = Guid.NewGuid().ToString("N");
            //user.Name = "hanzuxiang";

            //var List = AutoFacConfig.Resolve<IUserService>().Insert(user);
            //var list = _context.Query();
            //var context = new DBContext();
            //var scope = _dBContext.Database.BeginTransaction();
            //try
            //{
            //    _roleInfo.UpdateAttach(roleInfo);
            //    roleInfo.Name = "新管理员";
            //    //_roleInfo.SaveChanges();
            //    //var add = _context.Insert(user);
            //    ////_context.SaveChanges();
            //    //if (add != null)
            //    //{
            //    //    roleInfo.SupId = add.Guid;
            //    //    _roleInfo.Insert(roleInfo);
            //    //    //_roleInfo.SaveChanges();
            //    //}
            //    //scope.Commit();
            //    //_unitOfWork.SaveChanges();
            //}
            //catch (Exception ex)
            //{

            //    throw;
            //}
            //var result = _context.SaveChanges();
            //var GG = new JsonResult<User>
            //{
            //    code=0,
            //    data=list.ToList(),
            //    success=true,
            //    message="获取数据成功！"
            //};
            return View();
        }
        public IActionResult Main()
        {
            return View();
        }
        public IActionResult zixun()
        {
            return View();
        }
        public IActionResult Arc()
        {
            return View();
        }
        public IActionResult tongzhi()
        {
            return View();
        }
        public IActionResult jiyao()
        {
            return View();
        }
        public IActionResult jiankang()
        {
            return View();
        }
        public IActionResult szybh()
        {
            return View();
        }
        public IActionResult heliu()
        {
            return View();
        }
        public IActionResult fullcalendar()
        {
            return View();
        }

        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";

            return View();
        }

        public IActionResult Contact()
        {
            ViewData["Message"] = "Your contact page.";

            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
